﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ePioneer_ep_service : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HttpCookie cookie = Request.Cookies["Users"];
            if (cookie != null)
            {
                if (cookie["userid"] != "")
                {
                    hid_usertype.Value = cookie["userType"];
                    LabelUserId.Text = "用户名：" + cookie["userid"];
                    Session["userid"] = cookie["userid"];
                }
                LabelDay.Text = "到期日：您软件的到期日还剩" + cookie["leftDays"] + "天";
                if (cookie["endDate"] != "0" && cookie["endDate"].Length > 8)
                {
                    DateTime endDate = Convert.ToDateTime(cookie["endDate"]);
                    if (endDate > DateTime.Now)
                        LabelDay.Text = "到期日：您软件的到期日还剩" + (endDate.Date - DateTime.Now.Date).Days + "天";
                }
                if (cookie["timeType"] != "1")
                {
                    LabelDate.Text = "活动到期日：2011年10月14日";
                }
                GetMultiLogin();
            }

            if (Request["userid"] != null && Request["userid"] != "")
            {
                txt_UserName.Value = Request["userid"];
                if (Request["loginType"] != null && Request["loginType"] != "")
                {
                    hid_LoginType.Value = Request["loginType"];
                }
                else
                {
                    if (cookie["loginType"] != "")
                    {
                        hid_LoginType.Value = cookie["loginType"];
                    }
                }
            }
        }
    }

    public string strNickname = "<div class='cpzx_zc_yanz'>未验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(0);' /></div>";
    public string strEmail = "<div class='cpzx_zc_yanz'>未验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(1);' /></div>";
    public string strMobile = "<div class='cpzx_zc_yanz'>未验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(2);' /></div>";
    public string strEM = "<div class='cpzx_zc_yanz'>未验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(3);' /></div>";
    private void GetMultiLogin()
    {
        HttpCookie cookie = Request.Cookies["Users"];
        if (cookie != null)
        {
            if (cookie["userGuid"] != "")
            {
                hid_UserGuid.Value = cookie["userGuid"];//用户唯一值识别
            }
            //验证用户已绑定的登录方式和未绑定的登录方式，包括：益盟号(4)、手机号(3)、昵称(1)和邮箱(2)
            //调用接口获取已绑定的登录方式
            if (cookie["multiLogin"] != "")
            {
                //1昵称,2邮箱,4手机号,8EM号
                int multiLogin = Convert.ToInt32(cookie["multiLogin"]);
                if ((multiLogin & 1) == 1)
                {
                    strNickname = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                }
                if ((multiLogin & 2) == 2)
                {
                    strEmail = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(1);' /></div>";
                }
                if ((multiLogin & 4) == 4)
                {
                    strMobile = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17.jpg' width='73' height='24' style='cursor: pointer;' onclick='SetAccount(2);' /></div>";
                }
                if ((multiLogin & 8) == 8)
                {
                    strEM = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                }
            }

            //当前登录方式不可修改
            switch (cookie["loginType"])
            {
                case "1":
                    strNickname = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                    break;
                case "2":
                    strEmail = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                    break;
                case "3":
                    strMobile = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                    break;
                case "4":
                    strEM = "<div class='cpzx_zc_yanz'>已验证</div><div class='cpzx_zc_szbutton'><img src='../User/image/button1_17hui.jpg' width='73' height='24' style='cursor: pointer;' /></div>";
                    break;
            }
        }
    }
}